package cn.creditease.std.utils;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.UUID;

/**
 * @Description: 获取服务ip
 * @Author: kai.yang
 * @Date: 2019-08-08 16:12
 */
public class IpUtils {

    /**
     * 获取服务器ip
     */
    public static String getLocalIp() {
        try {
            InetAddress address = InetAddress.getLocalHost();

            return address.getHostAddress();
        } catch (UnknownHostException e) {
            //ip获取失败时，保证通过唯一值可以查询对应服务
            return UUID.randomUUID().toString();
        }
    }

}
